package com.hsylient.javase.chapter01;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

@Slf4j
public class MyOperator {

    // 普通的运算符
    @Test
    public void testOperator() {
        System.out.println(1 + 1);
        System.out.println(5 - 1);
        System.out.println(3 * 5);
        System.out.println(10 / 2);
        System.out.println(13 % 5);
    }

    /**
     * 一个整数被0除会得到一个异常
     * 一个浮点数被0除得到无穷大
     * Infinity ∞ 无穷大
     */
    @Test
    @SuppressWarnings("all")
    public void division() {
        System.out.println(23.0 / 0);
        System.out.println(12 / 0);
    }

    /**
     * strictfp == strict float point
     * 严格的浮点类型
     */
    @Test
    public strictfp void xxx() {
        System.out.println(10.0 / 3);
    }

    @Test
    public void testBitOperator() {
        System.out.println(10 & 13);
        System.out.println(18 ^ 17);
        System.out.println(~1);
    }

    // 混合运算符
    @Test
    public void testMixOperator() {
        int number = 0;
        number++;
        log.info(String.format("number的值为：%s", number));
        number += 2;
        log.info(String.format("number的值为：%s", number));
    }

    @Test
    public void testRelationOperator() {
        int number = 0;
        log.info(String.format("3比2大是真的吗 %s", 3 > 2));
    }

    @Test
    public void logicOperator() {
        boolean result = true && false;
        log.info(Boolean.toString(result));
    }

}
